package com.example.mapper;

import com.example.entity.FirstLabel;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FirstLabelMapper {
    /**
     * 新增一级分类标签
     */
    @Insert("insert into housekeeper.first (type, judge) values (#{type},#{judge});")
    void save(FirstLabel firstLabel);

    /**
     * 根据分类名查询主键
     * @param label1
     * @return
     */
    @Select("select id from housekeeper.first where type = #{label1};")
    Integer getByType(String label1);

    /**
     * 删除一级标签
     */
    void del(List<Integer> ids);

    /**
     * 遍历全部一级标签
     * @return
     */
    @Select("select * from housekeeper.first;")
    List<FirstLabel> selectAll();

    /**
     * 搜索一级标签的主键id
     * @return
     */
    @Select("select id from housekeeper.first;")
    List<Long> getId();

    @Select("select * from housekeeper.first where judge = #{judge};")
    List<FirstLabel> selectByJudge(int judge);

    @Select("select type from housekeeper.first where id = #{typeKey1};")
    String getNameById(int typeKey1);

    @Select("select * from housekeeper.first;")
    List<FirstLabel> getAll();
}
